package ezXpns.tests;

import static org.junit.Assert.*;

import java.util.List;

import org.junit.Test;

import ezXpns.*;


//@author A0086934R
public class BudgetChangeTest {
	
	@Test
	public void testConstructor() {
		BudgetChange budget1 = new BudgetChange();
		assertNotNull(budget1);
		
	}
	
	@Test
	public void testPositiveAmount() {
		BudgetChange budget2 = new BudgetChange();
		budget2.setAmount(1000);
		assertTrue(budget2.getAmount() == 1000);
		
		BudgetChange budget3 = new BudgetChange();
		budget3.setAmount(Float.MAX_VALUE + (float) 1);
		assertTrue(budget3.getAmount() == Float.MAX_VALUE);
	}
	
	@Test
	public void testNegativeAmount() {
		BudgetChange budget4 = new BudgetChange();
		budget4.setAmount(-Float.MAX_VALUE - (float) 1);
		assertTrue(budget4.getAmount() == -Float.MAX_VALUE);
	}
	
	@Test
	public void testTag() {
		BudgetChange budget5 = new BudgetChange();
		Tag tag1 = new Tag("a1", "b1");
		Tag tag2 = new Tag("a2");
		budget5.addTag(tag1);
		budget5.addTag(tag2);
		assertTrue(budget5.hasTag("a1"));
		assertTrue(budget5.hasTag("a2"));
		
		assertTrue(budget5.getTag("a1").equals(tag1));
		assertTrue(budget5.getTag("a2").equals(tag2));
		
		Iterable<Tag> tagList = budget5.getAllTags();
		int count = 0;
		for(Tag tag : tagList){
			count ++;
		}
		assertTrue(count == 2);
		
		String tagString = budget5.getTagsAsString();
		assertEquals("a1:b1 a2", tagString);
		
		budget5.setTagsFromString("a3:b3 a4");
		assertFalse(budget5.hasTag("a1"));
		assertFalse(budget5.hasTag("a2"));
		assertTrue(budget5.hasTag("a3"));
		assertTrue(budget5.hasTag("a4"));
		
		budget5.removeTag("a3");
		assertFalse(budget5.hasTag("a3"));
		budget5.removeTag("a4");
		assertFalse(budget5.hasTag("a4"));
		
	}
}
